graph TB
    subgraph "External Interfaces"
        CLI[CLI Interface]
        API[REST API]
        WEB[Future Web UI]
    end

    subgraph "Agent Runtime Layer"
        MANIFEST[Persona Manifest<br/>- Name/Role<br/>- Objectives<br/>- Traits]
        RUNTIME[Agent Runtime<br/>- Task Execution<br/>- Credit Management<br/>- Memory Integration]
        REASONING[Reasoning Engine<br/>- Task Classification<br/>- Context Analysis<br/>- Response Generation]
    end

    subgraph "Compute Ledger Service"
        LEDGER_API[Ledger API<br/>FastAPI Service<br/>Port 8080]
        ACCOUNTS[Account Management<br/>- Create/Query<br/>- Balance Tracking]
        TRANSACTIONS[Transaction Processing<br/>- Issue Credits<br/>- Charge/Transfer<br/>- Audit Trail]
        LEDGER_DB[(SQLite DB<br/>Accounts<br/>Ledger Entries)]
    end

    subgraph "Memory & Knowledge Layer"
        MEMORY_STORE[Memory Store<br/>- TF-IDF Vectors<br/>- Document Search<br/>- Bulk Operations]
        EVENT_LOG[Event Log System<br/>- Append-only Logs<br/>- Actor-based Structure<br/>- Plaintext Format]
        LOG_ROTATION[Log Rotation<br/>- Size/Age Limits<br/>- Compression<br/>- Archival]
    end

    subgraph "Governance System"
        TASKS[Task Management<br/>- Create/Update<br/>- Assignment<br/>- Status Tracking]
        COMMENTS[Collaboration<br/>- Comments<br/>- Task Updates<br/>- Multi-agent Coordination]
    end

    subgraph "Telemetry & Monitoring"
        LOGGING[Structured Logging<br/>structlog JSON]
        METRICS[Future Metrics<br/>Prometheus/ELK]
    end

    subgraph "Storage Layer"
        FS[File System<br/>./events/<br/>./archives/]
        DB[(Database<br/>compute_ledger.db)]
    end

    %% External connections
    CLI --> RUNTIME
    CLI --> TASKS
    API --> LEDGER_API
    WEB -.-> RUNTIME
    WEB -.-> TASKS

    %% Runtime connections
    RUNTIME --> REASONING
    RUNTIME --> MEMORY_STORE
    RUNTIME --> LEDGER_API
    RUNTIME --> EVENT_LOG
    MANIFEST --> RUNTIME

    %% Reasoning connections
    REASONING --> MEMORY_STORE

    %% Ledger connections
    LEDGER_API --> ACCOUNTS
    LEDGER_API --> TRANSACTIONS
    ACCOUNTS --> LEDGER_DB
    TRANSACTIONS --> LEDGER_DB

    %% Memory connections
    EVENT_LOG --> MEMORY_STORE
    EVENT_LOG --> LOG_ROTATION
    LOG_ROTATION --> FS
    MEMORY_STORE --> FS

    %% Governance connections
    TASKS --> EVENT_LOG
    COMMENTS --> EVENT_LOG
    TASKS --> FS

    %% Telemetry connections
    RUNTIME --> LOGGING
    LEDGER_API --> LOGGING
    TASKS --> LOGGING
    LOGGING -.-> METRICS

    %% Storage connections
    LEDGER_DB --> DB
    EVENT_LOG --> FS

    %% Styling
    classDef runtime fill:#e1f5fe,stroke:#01579b,stroke-width:2px
    classDef ledger fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    classDef memory fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px
    classDef governance fill:#fff3e0,stroke:#e65100,stroke-width:2px
    classDef external fill:#fce4ec,stroke:#880e4f,stroke-width:2px
    classDef storage fill:#f5f5f5,stroke:#424242,stroke-width:2px
    classDef telemetry fill:#fffde7,stroke:#f57f17,stroke-width:2px

    class RUNTIME,REASONING,MANIFEST runtime
    class LEDGER_API,ACCOUNTS,TRANSACTIONS,LEDGER_DB ledger
    class MEMORY_STORE,EVENT_LOG,LOG_ROTATION memory
    class TASKS,COMMENTS governance
    class CLI,API,WEB external
    class FS,DB storage
    class LOGGING,METRICS telemetry